<?
require("includes.php");

db_prepare($db_host,$db_name,$db_login,$db_password);

function db_test() {
  $err = mysql_errno();
  if($err != 0) {
    printf("%s<br>",mysql_error());
  }
} 

printf("%s","Setup starting<br>");

$rs = mysql_query("CREATE DATABASE WEBTODO;");
$rs = mysql_query("use WEBTODO;"); db_test();
// GLOBAL 

$rs = mysql_query("DROP TABLE global_password;");
$rs = mysql_query("CREATE TABLE IF NOT EXISTS global_password(".
		"f_id INT AUTO_INCREMENT PRIMARY KEY,".
		"f_Name TEXT,".
		"f_Password TEXT,".
		"f_TIMESTAMP TIMESTAMP".
		");"); db_test();


$rs = mysql_query("DROP TABLE global_projects;");
$rs = mysql_query("CREATE TABLE IF NOT EXISTS global_projects(".
		"f_id INT AUTO_INCREMENT PRIMARY KEY,".
		"f_Name TEXT,".
		"f_Description TEXT,".
		"f_TIMESTAMP TIMESTAMP".
		");"); db_test();

$rs = mysql_query("INSERT INTO global_password VALUES (0,'ADM','wtd_adm_pswd',NULL);");db_test();

$rs = mysql_query("DROP TABLE global_variables;");
$rs = mysql_query("CREATE TABLE IF NOT EXISTS global_variables(".
		"f_id INT AUTO_INCREMENT PRIMARY KEY,".
		"f_TIMESTAMP TIMESTAMP,".
		"f_Name TEXT,".
		"f_Value TEXT,".
		"f_Description TEXT,".
		"f_URL TEXT".
		");"); db_test();


$rs = mysql_query("REPLACE INTO global_variables VALUES (0,NULL,'MinVersion','1.95','','http://webtodo.svitonline.com/downloads/WebTodo_Install.exe');");db_test();
$rs = mysql_query("REPLACE INTO global_variables VALUES (0,NULL,'LastVersion','1.95','','http://webtodo.svitonline.com/downloads/WebTodo_Install.exe');");db_test();


printf("%s","Setup complete<br>");

db_close();
?>
